/**
 * Bakalarska prace - Inteligentni budik
 * @package sleepCatcher
 * @file FormAlarmSet.h
 * @author Jan Pesava - xpesav00
 * @email xpesav00@stud.fit.vutbr.cz
 * @date 24. 12. 2011
 */

#ifndef FORMALARMSET_H_
#define FORMALARMSET_H_

#include <FBase.h>
#include <FApp.h>
#include <FUi.h>

#include "models/SCAlarm.h"

using namespace Osp::Ui::Controls;

class FormAlarmSet :
	public Osp::Ui::Controls::Form,
	public Osp::Ui::IActionEventListener,
	public Osp::Ui::ITouchEventListener,
	public Osp::Ui::ITimeChangeEventListener
{

// Construction
public:
	FormAlarmSet();
	virtual ~FormAlarmSet();

// Constants
public:
	static const RequestId IDA_ALARM_SET = 200;
	static const RequestId IDA_ALARM_BACK = 201;
	enum AwakeType {MELODY, VIBRATION, MELODY_AND_VIBRATION};


//Attributes
private:
	SCAlarm *pAlarm;
	bool dealocAlarm;
	EditField *pTime;
	EditField *pRepeat;
	EditField *pName;
	EditField *pAwakeSound;
	Slider *pSoundLevel;
	EditField *pAwakeType;
	ScrollPanel* pScrollPanel;
	TimePicker* pTimePicker;

// Methods
public:
	bool Initialize(void);
	virtual result OnInitializing(void);
	virtual result OnTerminating(void);
	virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
	virtual void OnTouchDoublePressed (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchFocusIn (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchFocusOut (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchLongPressed (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchMoved (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchPressed (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnTouchReleased (const Osp::Ui::Control &source, const Osp::Graphics::Point &currentPosition, const Osp::Ui::TouchEventInfo &touchInfo);
	virtual void OnSliderBarMoved (Osp::Ui::Controls::Slider &source, int value);
	virtual void OnTimeChangeCanceled (const Osp::Ui::Control &source);
	virtual void OnTimeChanged (const Osp::Ui::Control &source, int hour, int minute);
	void Redraw();
	void Update();
	void SetDefaultValues();
	void SetAlarmAndSave();
	void CloseAndGoBack();
	void SetAlarm(SCAlarm* pAlarm);
	SCAlarm* GetAlarm();
	int GetFormId();
};

#endif /* FORMALARMSET_H_ */
